//常用方法
/**
 * 
 */
var homeFormater =  /(^\w+:\/\/[^\/#\?]*$)/
	, dirTrimer =  /[^\/\\]*([#\?].*)?$/
	, base = location.href.replace(homeFormater, "$1/"). replace(dirTrimer, "")
	, baseTags = document.getElementsByTagName("base");
/**
 * 计算绝对地址 
 * @private
 * @param {tring} url 路径地址
 * @return {string} 绝对路径
 * @static
 */
function computeURL(url)
{
	var rootMatcher =  /(^\w+:(?:(\/\/\/\w\:)|(?:\/\/[^\/]*))?)/
		, purl = url.replace(/[#\?].*$/, "").replace(/\\/g, "/")
		, surl = url.substr(purl.length);
	if (rootMatcher.test(purl))
	{
		return purl + surl;
	}
	else if (purl.charAt(0) == "/")
	{
		return rootMatcher.exec(base)[0] + purl + surl;
	}
	purl = base + purl;
	while (purl.length > (purl = purl.replace(/[^\/]+\/\.\.\//, "")).length)
	{
	}
	return purl + surl;
}
//处理HTML BASE 标记
if (baseTags)
{
	var href, i = baseTags.length - 1;
	for (; i >= 0; i--)
	{
		href = baseTags[i].href;
		if (href)
		{
			base = computeURL(href.replace(homeFormater, "$1/").replace(dirTrimer, ""));
			break;
		}
	}
}

homeFormater = dirTrimer = null;

/**
 * 工具类对象
 * @instance Object
 */
var CommonUtil = {
	/**
	 * 计算绝对地址 
	 * @private
	 * @param {tring} url 路径地址
	 * @return {string} 绝对路径
	 * @public 
	 * @member CommonUtil
	 * @static
	 */
	computeURL: computeURL
}